<?php
//全景视频
if(!defined('IN_T')){
	die('hacking attempt');
}

$vid = intval($_REQUEST['vid']);

if($vid>0){
	$video = $Db->query("select * from ".$Base->table('video')." where id=$vid","Row");
	if(!$video){
		exit('全景视频不存在！');
	}
	if(Common::is_mobile_visit()){
		Common::base_header("Location:".$_lang['cdn_host']."video/play.html?vid=".$video['id']."\n");
	}
	$tp->assign('tour_top_ad',Transaction::get_ad_by_postion(2));
	$tp->assign('tour_bottom_ad',Transaction::get_ad_by_postion(3));
	$tp->assign('video',$video);
	$tp->assign('title','六盘水'.$video['vname'].' |云上贵州-贵州六盘水VR全景图,VR全景视频,VR看凉都,VR看钟山,六盘水全景,中国凉都全景');
	$tp->assign('description',$video['profile']);
}
else{
	$act = $_REQUEST['act'];
	if($act=='list'){
		$page = intval($_REQUEST['page']);
		$page = $page<1?1:$page;
		$size =  24;
		$recommend = isset($_REQUEST['recommend']) ? intval($_REQUEST['recommend']) : 1;
		$list = get_video_projects($recommend,$page,$size);
		echo $Json->encode($list);
		exit;
	}
	$tp->assign('title','六盘水720视频,游走云端,云上贵州-贵州六盘水VR全景图,VR全景视频,VR看凉都,VR看钟山,六盘水全景,中国凉都全景');
}	

//提取视频项目
function get_video_projects($recommend,$page,$size){
	$sql = "select id,vname,thumb_path,browsing_num from ".$GLOBALS['Base']->table('video')." where 1 ";
	if($recommend>0){
		$sql .= "and recommend=1 ";
		$GLOBALS['tp']->assign('recommend',1);
	}
	$sql.=' limit '.($page-1)*$size.','.$size;
	$res = $GLOBALS['Db']->query($sql);
	return $res;
}
?>